package 线程.阻塞队列;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;

public class Cook extends Thread{
    ArrayBlockingQueue<String> queue;
    //创建传入阻塞队列的构造方法
    public Cook(ArrayBlockingQueue<String> queue){
        this.queue=queue;
    }
    @Override
    public void run() {
         while (true){
             try {
                 queue.put("食物");
                 System.out.println("厨师放了食物");
             } catch (InterruptedException e) {

             }
         }
    }
}
